﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace DR5.SPExtend
{
    class DataTableString : DataTable
    {
        public DataTableString()
        {
        }

        public DataTableString(string tableName)
            : base(tableName)
        {
            
        }

        public DataTableString AddColumn(string colName, Type type)
        {
            this.Columns.Add(colName, type);
            return this;
        }

        public void AddColumns(string[] colNames)
        {
            foreach (string colName in colNames)
            {
                this.Columns.Add(colName);
            }
        }

        public DataTableString AddColumn(string colName)
        {
            this.Columns.Add(colName);
            return this;
        }

        /// <summary>
        /// String Array must in pattern with column added
        /// </summary>
        /// <param name="rowData"></param>
        /// <returns></returns>
        public void AddRow(string[] rowData)
        {
            DataRow dr = this.Rows.Add();

            int i = 0;
            foreach (string s in rowData)
            {
                dr[i] = rowData[i];
                i++;
            }
        }
    }
}
